package com.example.zg.zg_312_ordering_new.activity;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.example.zg.zg_312_ordering_new.R;

public abstract class BaseActivity extends AppCompatActivity {
    protected int layout_file=R.layout.activity_main;
    abstract void initViews();
    abstract void initEvents();
    abstract void initData();
    void setLayout(int layout_file){
        setContentView(layout_file);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setLayout(layout_file);
        initViews();
        initEvents();
        initData();
    }
    public int getUser_id(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getInt("user_id",0);
    }
    public String getUser_password(){
        SharedPreferences sp;
        sp=getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getString("userpass","");
    }
    public void showToast(String content){
        Toast.makeText(this,content,Toast.LENGTH_LONG).show();
    }
}
